﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Entity;
using DAO;
using Library;
using System.Text.RegularExpressions;

namespace BO
{
    public class CustomerBO
    {
        CustomerDAO csDAO = new CustomerDAO();
        /// <summary>
        /// Lay danh sach khach hang dua voa list
        /// </summary>
        public List<CustomerEntity> LoadCustomer()
        {
            return csDAO.LoadCustomer();
        }

        /// <summary>
        /// Loc danh sach khach hang theo sale name
        /// </summary>
        public List<CustomerEntity> LoadCustomerBySaleName(string SaleName)
        {
            return csDAO.LoadCustomerBySale(SaleName);
        }

        /// <summary>
        /// Them khach hang
        /// </summary>
        /// <param name="cs">CustomerEntity</param>
        public void AddCustomer(CustomerEntity cs)
        {
            csDAO.AddCustomer(cs);
        }

        /// <summary>
        /// Xoa khac hang duoc chon
        /// </summary>
        /// <param name="sCustomerCode">ma khach hang, dang string</param>
        public void DeleteCustomer(string sCustomerCode)
        {
            csDAO.DeleteCustomer(sCustomerCode);
        }

        /// <summary>
        /// Tim kiem khach hang
        /// </summary>
        /// <param name="sCustomerCode">Tim kiem khach hang</param>
        public List<CustomerEntity> FindCustomer(string sInput)
        {
            sInput = ConvertString.ConvertToUnSign(sInput.ToLower());
            return csDAO.FindCustomer(sInput);
        }

        /// <summary>
        /// Tim kiem khach hang
        /// </summary>
        /// <param name="sCustomerCode">Tim kiem khach hang</param>
        public List<CustomerEntity> FindCustomerBy(string sInput, string sBy)
        {
            sInput = ConvertString.ConvertToUnSign(sInput.ToLower());
            return csDAO.FindCustomerBy(sInput, sBy);
        }

        /// <summary>
        /// Sua thong tin khac hahng
        /// </summary>
        /// <param name="cs">CustomerEntity</param>
        public void EditCustomer(CustomerEntity cs)
        {
            csDAO.EditCustomer(cs);
        }

        /// <summary>
        /// Sua thong tin khac hahng
        /// </summary>
        /// <param name="cs">CustomerEntity</param>
        public void EditAuthorize(string CustomerCode, string FromSale, string ToSale, DateTime FromDate, DateTime ToDate)
        {
            csDAO.EditAuthorize(CustomerCode, FromSale, ToSale, FromDate, ToDate);
        }

        public CustomerEntity getCustomerInfo(string sCustomerID)
        {
            return csDAO.getInfoCustomer(sCustomerID);
        }

        /// <summary>
        /// Check customer code
        /// </summary>
        /// <param name="CS">customer code</param>
        public bool CheckCode(string code)
        {
            return csDAO.CheckCode(code);
        }

    }
}
